﻿
Imports System.IO
Imports xmlctrl
Imports xhtmlctrl

Public Class flashplayer
    Inherits div

    Public Class datasource
        Public link As String = Nothing
        Public width As String = Nothing
        Public height As String = Nothing
        Public noflashImage As String = Nothing
    End Class

    Private Shared Sub setSize(ByVal c As xhtmlControl, ByVal ds As datasource)
        assert(Not c Is Nothing, "c is nothing.")
        assert(Not ds Is Nothing, "ds is nothing.")

        If Not isemptystring(ds.width) Then
            c.width = ds.width
        End If
        If Not isemptystring(ds.height) Then
            c.height = ds.height
        End If
    End Sub

    Public Sub setData(ByVal ds As datasource)
        assert(Not ds Is Nothing, "ds is nothing.")
        assert(Not ds.link Is Nothing, "ds.link is nothing.")

        Dim obj As [object] = Nothing
        obj = New [object]()
        obj.type = network.http.contentType.shockwave_flash
        obj.data = ds.link
        setSize(obj, ds)
        addchild(obj)

        Dim param As param = Nothing
        param = New param()
        param.name = "movie"
        param.value = ds.link
        obj.addchild(param)

        If Not isemptystring(ds.noflashImage) Then
            Dim img As img = Nothing
            img = New img()
            img.src = ds.noflashImage
            setSize(img, ds)
            obj.addchild(img)
        End If
    End Sub

    Public Sub New(ByVal ds As datasource, Optional ByVal buff As Stream = Nothing)
        Me.New(buff)
        setData(ds)
    End Sub

    Public Sub New(Optional ByVal buff As Stream = Nothing)
        MyBase.New(buff)
    End Sub
End Class
